package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 查询购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 修改购物车
     * @param shoppingCartOne
     * @return
     */
    int update(ShoppingCart shoppingCartOne);

    /**
     * 新增购物车数据
     * @param shoppingCart
     * @return
     */
    int insert(ShoppingCart shoppingCart);

    /**
     * 删除购物车
     * @param shoppingCartOne
     * @return
     */
    @Delete("delete from shopping_cart where id = #{id}")
    int deleteOneById(ShoppingCart shoppingCartOne);

    /**
     * 清空购物车
     * @param userId
     * @return
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    int deleteAllByUserId(Long userId);

    int insertBatch(List<ShoppingCart> shoppingCartList);
}
